package com.xxx.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/19 14:52
 * @Copyright 博为峰
 */
public class DateDemo {
    public static void main(String[] args) {
//        m1();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //日期对象-->字符串
//        String s = format.format(new Date());
//        System.out.println("s = " + s);

        String s2 = "2021-07-19 15:27:23";
        try {
            //字符串-->日期对象
            Date date = format.parse(s2);
            System.out.println(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }

    public static void m1() {
        Date date = new Date();//封装的是当前时间
        System.out.println(date);
        long time = date.getTime();
//        System.out.println("time = " + time);//1626677810055

        System.out.println(new Date(1626677810055L));
    }

    //2008-08-08距离现在多少天

}
